Skip to content

simplify the implement of mark_sleep and mark_woken#68

Open
glorv wants to merge 1 commit intotikv:masterfrom
glorv:simple-spawn
Open

simplify the implement of mark_sleep and mark_woken#68
glorv wants to merge 1 commit intotikv:masterfrom
glorv:simple-spawn

Conversation

@glorv
Copy link
Contributor

@glorv glorv commented Aug 16, 2022

No description provided.

Signed-off-by: glorv <glorvs@163.com>
pub fn mark_sleep(&self) -> bool {
let mut cnt = self.active_workers.load(Ordering::SeqCst);
loop {
if is_shutdown(cnt) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, the active count should be not important once the pool is shut down.

@BusyJay Is there any special reason to check shutdown first?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Combining a loop and compare_exchange_weak just to be more performant when there is something to check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants